/*
 * uart_proxy.h - 串口代理头文件
 *
 * Author: xiaobo@YGL (xiaobocwb@gmail.com)
 * Version: 1.0.0
 * Date: 2025-01-19
 */

#ifndef __UART_PROXY_H__
#define __UART_PROXY_H__

#include "stdint.h"
#include "stdbool.h"
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif


#define LOGI_(fmt, ...) do{                                             \
                            println(fmt, ##__VA_ARGS__);   \
                        }while(0)
#define LOGI(fmt, ...) LOGI_("[I] " fmt "\r\n", ##__VA_ARGS__)
#define LOGE(fmt, ...) LOGI_("[E] " fmt "\r\n", ##__VA_ARGS__)
#define LOGD(fmt, ...) LOGI_("[D] " fmt "\r\n", ##__VA_ARGS__)

typedef struct {
    // 升级完成回调
    void (*ota_update_complete_callback)(void);
    // 收到MQTT消息回调
    void (*mqtt_receive_callback)(uint8_t *data, uint16_t len);
} uart_proxy_cb_ops_t;

bool uart_proxy_init(uint8_t port, uint32_t baudrate, const uart_proxy_cb_ops_t *ops);
bool uart_proxy_deinit(void);
bool uart_proxy_mqtt_publish(const uint8_t *payload, size_t len);

#ifdef __cplusplus
}
#endif

#endif // __UART_PROXY_H__


